module keypadtest();
	reg clk, rst;
		reg[4:0] out_sel;
	
	reg press_1, press_2, press_3, press_4, press_5, press_6, press_7, press_8, press_9, press_0, press_up, press_down, press_left, press_right, press_unit, press_tare, press_enter, press_scrl_left, press_scrl_right, press_main;
	
	wire rowA, rowB, rowC, rowD, colA, colB, colC, colD, colE;
	wire[5:0] press;

	keypad keys(clk, rst, rowA, rowB, rowC, rowD, colA, colB, colC, colD, colE, out_sel, press);
	KP kp(rowA, rowB, rowC, rowD, colA, colB, colC, colD, colE, press_1, press_2, press_3, press_4, press_5, press_6, press_7, press_8, press_9, press_0, press_up, press_down, press_left, press_right, press_unit, press_tare, press_enter, press_scrl_left, press_scrl_right, press_main);

	initial begin
		rst = 1;
		clk = 0;
		#5 rst = 0;
		#5 rst = 1;
	end
	
	always begin
		#5 clk = ~clk;
	end
	
	always begin
		#8 {press_1, press_2, press_3, press_4, press_5, press_6, press_7, press_8, press_9, press_0, press_up, press_down, press_left, press_right, press_unit, press_tare, press_enter, press_scrl_left, press_scrl_right, press_main} = $random;
	end
	
	

endmodule



module KP(rowA, rowB, rowC, rowD, colA, colB, colC, colD, colE, press_1, press_2, press_3, press_4, press_5, press_6, press_7, press_8, press_9, press_0, press_up, press_down, press_left, press_right, press_unit, press_tare, press_enter, press_scrl_left, press_scrl_right, press_main);
	input rowA, rowB, rowC, rowD;
	input press_1, press_2, press_3, press_4, press_5, press_6, press_7, press_8, press_9, press_0, press_up, press_down, press_left, press_right, press_unit, press_tare, press_enter, press_scrl_left, press_scrl_right, press_main;
	output colA, colB, colC, colD, colE;
		
	assign colA = (press_1 & rowA) | (press_4 & rowB) | (press_7 & rowC) | (press_scrl_left & rowD);
	assign colB = (press_2 & rowA) | (press_5 & rowB) | (press_8 & rowC) | (press_0 & rowD);
	assign colC = (press_3 & rowA) | (press_6 & rowB) | (press_9 & rowC) | (press_scrl_right & rowD);
	assign colD = (press_up & rowA) | (press_down & rowB) | (press_left & rowC) | (press_right & rowD);
	assign colE = (press_main & rowA) | (press_unit & rowB) | (press_tare & rowC) | (press_enter & rowD);
	

	
	
	
endmodule